<template>
	<view
		:style="{
			backgroundColor: bg,
			borderRadius: radius,
		}"
	>
		<view
			class="flex justify-between align-center"
			:style="{
				height: titleHeight,
				padding: cardPadding
			}"
		>
			<view class="flex align-center">
				<u-icon
					v-if="titleIcon && iconType === 'uview'"
					:name="titleIcon"
					:size="titleIconSize"
					:color="titleIconColor"
					style="margin-top: 3px; margin-right: 3px;"
				/>
				
				<text
					v-if="titleIcon && iconType === 'custom'"
					:class="'mar-r-5 iconfont ' + titleIcon"
					:style="{
						fontSize: titleIconSize,
						color: titleIconColor
					}"
				></text>
				
				
				<view class="pos-r">
					<text
						:style="{
							fontSize: titleSize,
							fontWeight: isBold ? 'bolder' : 'normal'
						}"
					>
						{{ title }}
					</text>
					
					<view
						v-if="isMsg && msgCount !== 0"
						class="flex align-center justify-center pos-a"
						:style="{
							right: '-15px',
							top: '-10px',
							zIndex: 99999,
							width: '20px',
							height: '20px',
							background: '#ff0000',
							color: '#fff',
							fontSize: '10px',
							borderRadius: '50%'
						}"
					>
						<text>
							{{ msgCount <= 99 ? msgCount : '99+' }}
						</text>
					</view>
				</view>
			</view>
			
			<view
				v-if="isRightContent"
				class="font-14"
				@click="handleRightClick()"
			>
				<text
					v-if="rightIcon"
					:class="'iconfont ' + rightIcon"
					:style="{
						marginRight: rightContent ? '5px' : '0px',
					}"
				></text>
				
				<text v-if="rightContent">{{ rightContent }}</text>
			</view>
		</view>
		
		<Lines w="100%" bg="#f0f0f0" h="2px" />
		
		<view class="flex align-center w-px-60 text-center mar-x-10 mar-t-10 pad-b-10">
			<view
				class="mar-r-20 text-nowrap"
				v-for="(item, index) in list"
				:key="index"
				@click="handleModuleClick(item)"
			>
				<view class="flex justify-center pos-r">
					<u-icon
						v-if="item.icon && item.iconType === 'uview'"
						:name="item.icon"
						:size="item.iconSize"
						:color="item.iconColor ? item.iconColor : titleIconColor"
					/>
						
					<text
						v-if="item.icon && item.iconType === 'custom'"
						:class="'mar-r-5 iconfont ' + item.icon"
						:style="{
							fontSize: item.iconSize,
							color: item.iconColor ? item.iconColor : titleIconColor
						}"
					></text>
					
					<view
						v-if="item.isMsg && item.msgCount !== 0"
						class="flex align-center justify-center pos-a"
						:style="{
							right: '-5%',
							top: '-10px',
							zIndex: 99999,
							width: '20px',
							height: '20px',
							background: '#ff0000',
							color: '#fff',
							fontSize: '10px',
							borderRadius: '50%'
						}"
					>
						<text>
							{{ item.msgCount <= 99 ? item.msgCount : '99+' }}
						</text>
					</view>
				</view>
				
				<view
					class="mar-t-5"
					:style="{
						fontSize: pageNameSize,
					}"
				>
					<text>{{ item.title }}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import Lines from '@/components/Lines/index'
	
	export default {
		components: {
			Lines,
		},
		
		props: {
			// 卡片背景
			bg: {
				type: String,
				default: '#ffffff'
			},
			
			// 卡片内边距
			cardPadding: {
				type: String,
				default: '0 5px'
			},
			
			// 圆角
			radius: {
				type: String,
				default: '10px'
			},
			
			// 菜单id
			menuId: {
				type: String,
				default: ''
			},
			
			// 是否展示数字提醒
			isMsg: {
				type: Boolean,
				default: false,
			},
			
			// 如果展示数字提醒，那么展示的数字是多少
			msgCount: {
				type: Number,
				default: 0
			},
			
			// 图标类型，custom: 自定义，uview：uview框架自带
			iconType: {
				type: String,
				default: ''
			},
			
			// 标题图标大小
			titleIcon: {
				type: String,
				default: ''
			},
			
			// 标题图标大小
			titleIconSize: {
				type: String | Number,
				default: 30
			},
			
			// 标题图标颜色
			titleIconColor: {
				type: String,
				default: '#3c9cff'
			},
			
			// 标题
			title: {
				type: String,
				default: ''
			},
			
			// 标题是否加粗
			isBold: {
				type: Boolean,
				default: true
			},
			
			// 标题字体大小
			titleSize: {
				type: String,
				default: '14px'
			},
			
			// 标题区域高度
			titleHeight: {
				type: String,
				default: '60px'
			},
			
			// 是否展示右侧内容
			isRightContent: {
				type: Boolean,
				default: false
			},
			
			// 右侧图标
			rightIcon: {
				type: String,
				default: ''
			},
			
			// 右侧内容
			rightContent: {
				type: String,
				default: ''
			},
			
			// 列表数据
			list: {
				type: Array,
				default: []
			},
			
			// 页面名称大小
			pageNameSize: {
				type: String,
				default: '14px'
			}
		},
		
		data() {
			return {
				
			}
		},
		
		onLoad() {
			
		},
		
		methods: {
			// 点击组件中模块的回调
			handleModuleClick(item) {
				this.$emit('handleModuleClick', item, this.menuId)
			},
			
			// 点击右侧的回调
			handleRightClick() {
				this.$emit('handleRightClick', this.menuId)
			},
		},
	}
</script>

<style lang="scss" scoped>
	
</style>